/*
 * @copyright 2010 Gerald Jacobson
 * @license GNU General Public License
 * 
 * This file is part of Descent Assistant.
 *
 * Descent Assistant is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Descent Assistant is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Descent Assistant.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.amphiprion.descenttool.util;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class PreferenceUtil {
	private static SharedPreferences sharedPreferences;

	public static enum Preference {
		DISABLE_VIBRATION, UPDATE_CLICK_MODE, ENCOUNTER_MODE, LEVEL_BEAST, LEVEL_HUMANOID, LEVEL_ELDRITCH, NB_PLAYER, LEVEL_LIEUTENANT
	}

	public static void init(SharedPreferences sharedPreferences) {
		PreferenceUtil.sharedPreferences = sharedPreferences;
	}

	public static String getString(Preference key, String defValue) {
		return sharedPreferences.getString(key.name(), defValue);
	}

	public static boolean getBoolean(Preference key, boolean defValue) {
		return sharedPreferences.getBoolean(key.name(), defValue);
	}

	public static int getInt(Preference key, int defValue) {
		return sharedPreferences.getInt(key.name(), defValue);
	}

	public static void putString(Preference key, String value) {
		Editor edit = sharedPreferences.edit();
		edit.putString(key.name(), value);
		edit.commit();
	}

	public static void putInt(Preference key, int value) {
		Editor edit = sharedPreferences.edit();
		edit.putInt(key.name(), value);
		edit.commit();
	}

	public static void putBoolean(Preference key, boolean value) {
		Editor edit = sharedPreferences.edit();
		edit.putBoolean(key.name(), value);
		edit.commit();
	}

}
